package com.redis.transaction;

import com.redis.transaction.enums.GameTransactionCause;
import com.redis.transaction.exception.GameTransactionException;


public interface GameTransactionInterface {

    /**
     * 激活，构造
     */
    int ACTIVE = 0;
    /**
     * 尝试提交
     */
    int TRYCOMMITED = 1;
    /**
     * 正式提交
     */
    int COMMITED = 2;
    /**
     * 正式回滚
     */
    int ROLLEDBACK = 3;

    /**
     * 事务提交
     *
     * @throws GameTransactionException
     */
    void commit() throws GameTransactionException;

    /**
     * 事务回滚
     *
     * @throws GameTransactionException
     */
    void rollback() throws GameTransactionException;

    /**
     * 是否可以提交
     *
     * @return
     */
    boolean canCommit();

    /**
     * 尝试性提交
     */
    void trycommit() throws GameTransactionException;

    /**
     * 获取事务原因
     *
     * @return
     */
    GameTransactionCause getCause();

    /**
     * 是否可以创建锁
     *
     * @return
     */
    boolean createGameTransactionLock() throws GameTransactionException;


    /**
     * 释放锁
     *
     * @return
     */
    void releaseGameTransactionLock();
}
